This change makes babl buildable on Windows.
authorMichael Schumacher <schumaml@cvs.gnome.org>
Sat, 6 Jan 2007 14:21:14 +0000 (14:21 +0000)
committerMichael Schumacher <schumaml@src.gnome.org>
Sat, 6 Jan 2007 14:21:14 +0000 (14:21 +0000)
2007-01-06  Michael Schumacher  <schumaml@cvs.gnome.org>

        This change makes babl buildable on Windows.

* configure.ac: Add a check for function dlopen and disabled
static libs by default. Check for gettimeofday by using
AC_REPLACE_FUNCS.

* babl/babl-internal.h: Add definitions for srandom and radnom to
srand and rand for the windows platform.
* babl/babl-conversion.c
* babl-model.c: Include babl-internal.h after math.h

* babl/babl-extension.c: Use #ifdef HAVE_DLOPEN to hide dl* if it
is not available.

* babl/Makefile.am: Removed win32_libs and added @LTLIBOBJS@ to
LIBADD to get the replacement for gettimeofday linked in if
needed.

* babl/gettimeofday.c: New file to provide a replacement for
gettimeofday, only used on Windows yet.

svn path=/trunk/; revision=193

ChangeLog
babl/Makefile.am
babl/babl-conversion.c
babl/babl-extension.c
babl/babl-internal.h
babl/babl-model.c
babl/gettimeofday.c [new file with mode: 0644]
configure.ac

index 16ee3d8557c89e91e47640e2d3f091b01e488d1a..3774cff1fb6cd1d01e4a1ed76a036c819f4025cf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2007-01-06  Michael Schumacher  <schumaml@cvs.gnome.org>
+
+        This change makes babl buildable on Windows.
+       
+       * configure.ac: Add a check for function dlopen and disabled
+       static libs by default. Check for gettimeofday by using
+       AC_REPLACE_FUNCS.
+       
+       * babl/babl-internal.h: Add definitions for srandom and radnom to
+       srand and rand for the windows platform.
+       * babl/babl-conversion.c 
+       * babl-model.c: Include babl-internal.h after math.h
+
+       * babl/babl-extension.c: Use #ifdef HAVE_DLOPEN to hide dl* if it
+       is not available.
+
+       * babl/Makefile.am: Removed win32_libs and added @LTLIBOBJS@ to
+       LIBADD to get the replacement for gettimeofday linked in if
+       needed. 
+
+       * babl/gettimeofday.c: New file to provide a replacement for
+       gettimeofday, only used on Windows yet.
+
 2007-01-06  Michael Schumacher  <schumaml@cvs.gnome.org>
 
        * Makefile.am: don't go into the extensions subdirectory on
index 81b28f942650ef2e134a413bfb45fcd6ab0ed475..6d261325d219be9dfbba0760c13b2a09fea40f5a 100644 (file)
@@ -1,7 +1,6 @@
 ## Source directory
 
 if OS_WIN32
-win32_libs = -lgw32c -lole32 -luuid -lwsock32
 no_undefined = -no-undefined
 endif
 
@@ -52,7 +51,7 @@ lib_LTLIBRARIES= libbabl.la
 libbabl_la_SOURCES= $(h_sources) $(c_sources)
 libbabl_la_LIBADD=\
        base/libbase.la \
-       ${win32_libs}
+       @LTLIBOBJS@
 
 libbabl_la_LDFLAGS= \
        -version-info $(BABL_LIBRARY_VERSION) \
index 7d472aa8c67d36e8155538b8927d28e638d583fa..2fe140f8a18873a1413c72b6b13668bed1ca0ca1 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "babl-internal.h"
-#include "babl-db.h"
+
 #include <string.h>
 #include <stdarg.h>
 #include <math.h>
+#include "babl-internal.h"
+#include "babl-db.h"
 
 static int
 each_babl_conversion_destroy (Babl *babl,
index 49c9f161cddc6d7d7ed45733e8d54dba84beb194..8db2601ecc959f033083ea402850d9fad788d6a4 100644 (file)
@@ -140,11 +140,6 @@ destroy_hook (void)
 
 #ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
-#else
-void  *dlopen(const char *, int);
-void  *dlsym(void *, const char *);
-int    dlclose(void *);
-char  *dlerror(void);
 #endif
 
 #ifndef RTLD_NOW
@@ -167,6 +162,7 @@ babl_extension_load (const char *path)
 {
   Babl *babl             = NULL;
 
+#ifdef HAVE_DLOPEN
   /* do the actual loading thing */
   void *dl_handle        = NULL;
   int  (*init)    (void) = NULL;
@@ -196,6 +192,7 @@ babl_extension_load (const char *path)
       babl_log ("babl_extension_init() in extension '%s' failed (return!=0)", path);
       return load_failed (babl);
     }
+#endif
 
   if (babl_db_insert (db, babl) == babl)
     {
@@ -340,7 +337,7 @@ each_babl_extension_destroy (Babl *babl,
 {
   if (babl->extension.destroy)
     babl->extension.destroy();
-#ifdef BABL_DYNAMIC_EXTENSIONS
+#ifdef HAVE_DLOPEN
   if (babl->extension.dl_handle)
     dlclose (babl->extension.dl_handle);
 #endif
index 06d69c27ca69d9b907f606ac74214a577a0fb3ee..12fe70c457815cebb237580b2e3183fd320b8b7b 100644 (file)
 #include "babl-util.h"
 #include "babl-memory.h"
 
+/* redefining some functions for the win32 platform */
+#ifdef _WIN32
+#define srandom srand
+#define random  rand
+#endif
 
 Babl   * babl_conversion_find           (void           *source,
                                          void           *destination);
index 573e2f301d4cb481be497ebe87383b92e7d82eb4..2956aca265480aa00770f4d794d3de85ef88d705 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
-#include "babl-internal.h"
 #include <string.h>
 #include <stdarg.h>
 #include <math.h>
+#include "babl-internal.h"
 #include "babl-db.h"
 
 
diff --git a/babl/gettimeofday.c b/babl/gettimeofday.c
new file mode 100644 (file)
index 0000000..c106082
--- /dev/null
@@ -0,0 +1,66 @@
+/*\r
+ * timeval.h    1.0 01/12/19\r
+ *\r
+ * Defines gettimeofday, timeval, etc. for Win32\r
+ *\r
+ * By Wu Yongwei\r
+ *\r
+ */\r
+\r
+#ifdef _WIN32\r
+\r
+#define WIN32_LEAN_AND_MEAN\r
+#include <windows.h>\r
+#include <time.h>\r
+\r
+#ifndef __GNUC__\r
+#define EPOCHFILETIME (116444736000000000i64)\r
+#else\r
+#define EPOCHFILETIME (116444736000000000LL)\r
+#endif\r
+\r
+struct timeval {\r
+    long tv_sec;        /* seconds */\r
+    long tv_usec;  /* microseconds */\r
+};\r
+\r
+struct timezone {\r
+    int tz_minuteswest; /* minutes W of Greenwich */\r
+    int tz_dsttime;     /* type of dst correction */\r
+};\r
+\r
+\r
+int gettimeofday(struct timeval *tv, struct timezone *tz)\r
+{\r
+    FILETIME        ft;\r
+    LARGE_INTEGER   li;\r
+    __int64         t;\r
+    static int      tzflag;\r
+\r
+    if (tv)\r
+    {\r
+        GetSystemTimeAsFileTime(&ft);\r
+        li.LowPart  = ft.dwLowDateTime;\r
+        li.HighPart = ft.dwHighDateTime;\r
+        t  = li.QuadPart;       /* In 100-nanosecond intervals */\r
+        t -= EPOCHFILETIME;     /* Offset to the Epoch time */\r
+        t /= 10;                /* In microseconds */\r
+        tv->tv_sec  = (long)(t / 1000000);\r
+        tv->tv_usec = (long)(t % 1000000);\r
+    }\r
+\r
+    if (tz)\r
+    {\r
+        if (!tzflag)\r
+        {\r
+            _tzset();\r
+            tzflag++;\r
+        }\r
+        tz->tz_minuteswest = _timezone / 60;\r
+        tz->tz_dsttime = _daylight;\r
+    }\r
+\r
+    return 0;\r
+}\r
+\r
+#endif /* _WIN32 */\r
index 4b9e996b4dc1002991736e366b4af82e7f4dd4a6..a07ebf4bf7ae978e44ec6d147cd6682c918d5a8b 100644 (file)
@@ -56,6 +56,7 @@ AC_SUBST(PACKAGE_NAME)
 AM_CONFIG_HEADER(config.h)
 AM_INIT_AUTOMAKE(no-define)
 
+AC_DISABLE_STATIC
 AC_PROG_CC
 AC_LIBTOOL_WIN32_DLL
 AM_PROG_LIBTOOL
@@ -162,6 +163,9 @@ dnl ===========================================================================
 AC_CHECK_LIB([dl], [dlopen], [DL_LIB="-ldl"])
 AC_SUBST(DL_LIB)
 
+AC_CHECK_FUNCS(dlopen)
+AC_REPLACE_FUNCS(gettimeofday)
+
 AC_DEFINE_UNQUOTED(BABL_PATH, "~/.babl-$BABL_API_VERSION:/usr/local/lib/babl-$BABL_API_VERSION:/usr/lib/babl-$BABL_API_VERSION", [search path for babl extensions (default value of enviroment variable)])
 AC_DEFINE(BABL_PATH_SEPERATOR, "/", [string used to seperate directories in a path string]) 
 AC_DEFINE(BABL_LIST_SEPERATOR, ':', [seperator between paths in BABL_PATH])